package com.nulldev.util.scripting.cup.vee.registers;

import java.math.BigInteger;
import java.util.concurrent.atomic.AtomicReference;

import com.nulldev.util.scripting.cup.vee.CUPRegister;

public class WideCUPRegister extends CUPRegister<BigInteger> {

	private final int registerID;

	public WideCUPRegister(final int registerID) {
		this.registerID = registerID;
	}

	private final AtomicReference<BigInteger> value = new AtomicReference<BigInteger>(BigInteger.valueOf(0L));

	@Override
	public CUPRegisterType getRegisterType() {
		return CUPRegisterType.WIDE;
	}

	@Override
	public void reset() {
		this.value.set(BigInteger.valueOf(0L));
	}

	@Override
	public BigInteger get() {
		return this.value.get();
	}

	@Override
	public void set(BigInteger value) {
		this.value.set(value);
	}

	@Override
	public boolean valuePresent() {
		return this.value.get() != null;
	}

	@Override
	public int getRegisterID() {
		return this.registerID;
	}

}
